home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / utilities / bmfc000.lha / BMFC / src / bmfc / error.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-31  |  953 b   |  51 lines

  1. /**************************************/
  2. /* error.c                            */
  3. /* for BMFC 0.00                      */
  4. /* Copyright 1992 by Adam M. Costello */
  5. /**************************************/
  6.  
  7.  
  8. #include "error.h"  /* Makes sure we're consistent with the prototypes. */
  9. #include "parse.h"
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <stdarg.h>
  13.  
  14.  
  15. const char *const outofmem = "Out of memory.\n";
  16.  
  17.  
  18. void warnf(const char *format, ...)
  19. {
  20.   va_list ap;
  21.  
  22.   va_start(ap,format);
  23.   vfprintf(stderr,format,ap);
  24.   va_end(ap);
  25.   fflush(stderr);
  26. }
  27.  
  28.  
  29. void failf(const char *format, ...)
  30. {
  31.   va_list ap;
  32.  
  33.   va_start(ap,format);
  34.   fputs("Error: ", stderr);
  35.   vfprintf(stderr,format,ap);
  36.   va_end(ap);
  37.   exit(EXIT_FAILURE);
  38. }
  39.  
  40.  
  41. void parsefailf(const char *format, ...)
  42. {
  43.   va_list ap;
  44.  
  45.   va_start(ap,format);
  46.   fprintf(stderr, "Error in line %4lu pos %3lu: ", linenum(), position());
  47.   vfprintf(stderr,format,ap);
  48.   va_end(ap);
  49.   exit(EXIT_FAILURE);
  50. }
  51.